//
//  MXCollocationTopView.m
//  MXの衣柜
//
//  Created by 马霄 on 15/8/6.
//  Copyright (c) 2015年 霄 马. All rights reserved.
//
#define WIDTH ([UIScreen mainScreen].bounds.size.width)
#define HEIGHT ([UIScreen mainScreen].bounds.size.height)
#import "MXCollocationTopView.h"

@interface MXCollocationTopView ()
@property (nonatomic, retain) NSMutableArray *stypeArray;
@property (nonatomic, retain) NSMutableArray *stypeLabelArray;
@property (nonatomic, retain) NSMutableArray *occasionArray;
@property (nonatomic, retain) NSMutableArray *occasionLabelArray;
@end
@implementation MXCollocationTopView
- (void)dealloc
{
    [_topViewStyleArray release];
    [_occasionLabelArray release];
    [_occasionArray release];
    [_stypeLabelArray release];
    [_stypeArray release];
    [_OccasionTopiclabel release];
    [_occasionView release];
    [_StyleTopiclabel release];
    [_styleView release];
    [_matchLabel release];
    [super dealloc];
}
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
         self.topViewStyleArray = [NSMutableArray array];
        self.occasionView = [[[UIView alloc] init] autorelease];
        self.occasionView.backgroundColor = [UIColor orangeColor];
        [self addSubview:self.occasionView];
        
        self.OccasionTopiclabel = [[[UILabel alloc] init] autorelease];
        self.OccasionTopiclabel.backgroundColor = [UIColor redColor];
        [self.occasionView addSubview:self.OccasionTopiclabel];
        
        self.styleView = [[[UIView alloc] init] autorelease];
        self.styleView.backgroundColor = [UIColor greenColor];
        [self addSubview:self.styleView];
        
        self.StyleTopiclabel = [[[UILabel alloc] init] autorelease];
        self.StyleTopiclabel.backgroundColor = [UIColor yellowColor];
        [self.styleView addSubview:self.StyleTopiclabel ];
        
        self.matchLabel = [[[UILabel alloc] init] autorelease];
        self.matchLabel.text = @"";
        self.matchLabel.textAlignment = NSTextAlignmentCenter;
        self.matchLabel.backgroundColor = [UIColor cyanColor];
        [self addSubview:self.matchLabel];
        
        
     }
    return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    //全局数组初始化
    self.stypeArray = [NSMutableArray array];
    self.stypeLabelArray = [NSMutableArray array];
    
    self.occasionArray = [NSMutableArray array];
    self.occasionLabelArray = [NSMutableArray array];
    
   
    
    
//    CGFloat margin = 10;
    
    CGFloat ViewX = 0;
    CGFloat ViewY = HEIGHTPRO * 10;
    CGFloat ViewW = self.frame.size.width;
    CGFloat ViewH = HEIGHTPRO * 240;
    
    
    self.styleView.frame = CGRectMake(ViewX, ViewY, ViewW, ViewH);
    
    CGFloat LabelX = WIDTHPRO * 20;
    CGFloat LabelY = HEIGHTPRO * 10;
    CGFloat LabelW = WIDTHPRO * 40;
    CGFloat LabelH = HEIGHTPRO * 20;
    
    self.StyleTopiclabel.frame = CGRectMake(LabelX, LabelY, LabelW, LabelH);
    
    self.occasionView.frame = CGRectMake(ViewX, ViewY + ViewH + HEIGHTPRO * 10, ViewW, ViewH);
    
    self.OccasionTopiclabel.frame = CGRectMake(LabelX, LabelY, LabelW, LabelH);
    
    self.matchLabel.frame = CGRectMake(ViewX, HEIGHTPRO * 20 + 2 * ViewH, ViewW, HEIGHTPRO * (118 - 64));
//============================= 风格部分小标签 =================================
    NSInteger dex = 0;
    for (int i = 0; i < 4; i ++) {
        for (int j = 0; j < 2; j++) {
            UIImageView *StypeImageView = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTHPRO * 35 + i * WIDTHPRO * 80, WIDTHPRO * 30 + WIDTHPRO * 100 * j, WIDTHPRO * 60, HEIGHTPRO * 60)];
            StypeImageView.backgroundColor = [UIColor blueColor];
            StypeImageView.tag = 10000 + i;
            StypeImageView.layer.cornerRadius = WIDTHPRO * 30;
            StypeImageView.layer.masksToBounds = YES;
            [self.styleView addSubview:StypeImageView];
            UILabel *StypeLabel = [[UILabel alloc]  initWithFrame:CGRectMake(StypeImageView.frame.origin.x, StypeImageView.frame.origin.y + StypeImageView.frame.size.height, StypeImageView.frame.size.width, HEIGHTPRO * 30)];
            StypeLabel.tag = 1000 + dex;
            StypeLabel.backgroundColor = [UIColor magentaColor];
            StypeLabel.text = [NSString stringWithFormat:@"%ld", (long)StypeLabel.tag];
            [self.styleView addSubview:StypeLabel];
            dex++;
            //存入图片数组
            [self.stypeArray addObject:StypeImageView];
            //存入Label数组
            [self.stypeLabelArray addObject:StypeLabel];
        }
    }
//============================= 场合部分小标签 =================================

    NSInteger inex = 0;
    for (int i = 0; i < 4; i++) {
        UIImageView *OccasionImageView = [[[UIImageView alloc] initWithFrame:CGRectMake(WIDTHPRO * 35 + i * WIDTHPRO * 80, HEIGHTPRO * 30 , WIDTHPRO * 60, HEIGHTPRO * 60)] autorelease];
        OccasionImageView.backgroundColor = [UIColor purpleColor];
        OccasionImageView.layer.cornerRadius = WIDTHPRO * 30;
        OccasionImageView.tag = 1100 + inex;
        OccasionImageView.layer.masksToBounds = YES;
        [self.occasionView addSubview:OccasionImageView];
        
        
        UILabel *OccasionLabel = [[[UILabel alloc]  initWithFrame:CGRectMake(OccasionImageView.frame.origin.x, OccasionImageView.frame.origin.y + OccasionImageView.frame.size.height, OccasionImageView.frame.size.width, HEIGHTPRO * 30)] autorelease];
        OccasionLabel.tag = 1200 + inex;
        OccasionLabel.backgroundColor = [UIColor magentaColor];
        OccasionLabel.text = [NSString stringWithFormat:@"%ld", (long)OccasionLabel.tag];
        [self.occasionView addSubview:OccasionLabel];
        inex++;
        [self.occasionArray addObject:OccasionImageView];
        [self.occasionLabelArray addObject:OccasionLabel];
    }
    UIImageView *oneView = [[UIImageView alloc] initWithFrame:CGRectMake( WIDTHPRO * 35, HEIGHTPRO * 130, WIDTHPRO * 60, HEIGHTPRO * 60)];
    oneView.backgroundColor = [UIColor redColor];
    oneView.layer.cornerRadius = WIDTHPRO * 30;
    oneView.layer.masksToBounds = YES;
    [self.occasionView addSubview:oneView];
    [self.occasionArray addObject:oneView];
    
    
    UILabel *oneLabel = [[UILabel alloc] initWithFrame:CGRectMake(oneView.frame.origin.x, oneView.frame.origin.y + oneView.frame.size.height, oneView.frame.size.width, HEIGHTPRO * 30)];
    oneLabel.backgroundColor = [UIColor grayColor];
    [self.occasionView addSubview:oneLabel];
    [self.occasionLabelArray addObject:oneLabel];
    
//============================= 线 + 字 =================================
    UIView *line1 = [[UIView alloc] initWithFrame:CGRectMake(WIDTHPRO * 40, HEIGHTPRO * 26.5, WIDTHPRO * 100, HEIGHTPRO * 1)];
    line1.backgroundColor = [UIColor redColor];
    [self.matchLabel addSubview:line1];
    
    UIView *line2 = [[UIView alloc] initWithFrame:CGRectMake(WIDTHPRO * (40 + 187.5), HEIGHTPRO * 26.5, WIDTHPRO * 100, HEIGHTPRO * 1)];
    line2.backgroundColor = [UIColor redColor];
    [self.matchLabel addSubview:line2];
    
    UILabel *wordLabel = [[UILabel alloc] initWithFrame:CGRectMake(WIDTHPRO * 157, HEIGHTPRO * 12, WIDTHPRO * 60, HEIGHTPRO * 30)];
    wordLabel.backgroundColor = [UIColor whiteColor];
    wordLabel.text = @"搭配精选";
    wordLabel.font = [UIFont systemFontOfSize:12];
    wordLabel.textAlignment = NSTextAlignmentCenter;
    [self.matchLabel addSubview:wordLabel];
    
    
    
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
